import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        navActive: 'Home', // 顶部导航
        loading: false, // 全局loading状态
        layout: [
            // {"x": 0, "y": 0, "w": 2, "h": 2, "i": "0"},
        ],
        gridlayout: null,
        // 保存页面配置
        pageList:[
            // {
            //     name: '',
            //     data: {}
            // }
        ],
        pageLayout: [], // 监控中心当前页配置
        leftWidth: '0px',
        setWidth: '0px',
        backgroundColor: 'blue'
    },
    getters: {
        navGet: state => state.navActive,
        loadingGet: state => state.loading,
        layoutGet: state => state.layout,
        gridlayoutGet: state => state.gridlayout,
        leftWidthGet: state => state.leftWidth,
        setWidthGet: state => state.setWidth,
        pageLayoutGet: state => state.pageLayout,
        backgroundColorGet: state => state.backgroundColor,
    },
    mutations: {
        navMut (state, val) {
            state.navActive = val;
        },
        loadingMut (state, val) {
            state.loading = val;
        },
        layoutMut (state, val) {
            state.layout = val;
        },
        pageLayoutMut (state, val) {
            state.pageLayout = val;
        },
        leftWidthMut (state, val) {
            state.leftWidth = val;
        },
        setWidthMut (state, val) {
            state.setWidth = val;
        },
        backgroundColorMut (state, val) {
            state.backgroundColor = val;
        }
    },
    actions: {
        navAct(content) {
            content.commit('navMut');
        },
        loadingAct(content) {
            content.commit('loadingMut');
        },
        pageLayoutAct(content) {
            content.commit('pageLayoutMut');
        }
    },
    modules: {},
});
